import { FunctionComponent } from "react";
import style from "./index.less";

export interface IGameOverProps {
    /** 是否显示 */
    visible?: boolean;
    /** 分数 */
    score: number;
    /** 重开游戏 */
    onReStart?: () => void;
}

/** 游戏结束 */
const GameOver: FunctionComponent<IGameOverProps> = ({ visible = false, score = 0, onReStart }) => {

    const reStart = () => {
       onReStart?.()
    }

    return (
        visible ? <div className={style.game_result}>
            <div className={style.result_score}>你的最终得分是: {score}分</div>
            <div className={style.result_manipulate}>
                <div className={style.btn} onClick={reStart}>返回主页</div>
                <div className={style.btn} onClick={reStart}>查看排名</div>
            </div>
        </div> : null
    )
}

export default GameOver;